<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet"/>
    <script type="text/javascript" charset="utf-8">
      	mui.init();
      	mui.plusReady(function(){
      		var userName = document.getElementById("userName");
      		var phoneNumber = document.getElementById("phoneNumber");
      		var password = document.getElementById("password");
      		var registerBtn = document.getElementById("registerBtn");
      		var phoneNumberInt = parseInt(phoneNumber.value);
      		
      		registerBtn.addEventListener('tap',function(){
      			if(userName.value.length == 0){
      				plus.ui.toast("用户名不能为空");
      				return;
      			}
      			if(phoneNumber.value.length == 0){
      				plus.ui.toast("手机号不能为空");
      				return;
      			}
      			if(phoneNumber.value.length != 11){
      				plus.ui.toast("手机号必须为11位");
      				return;
      			}
      			if(isNaN(phoneNumberInt)){
      				plus.ui.toast("手机号必须为数字");
      				return;
      			}
      			if(password.value.length == 0){
      				plus.ui.toast("密码不能为空");
      				return;
      			}
      			console.log(JSON.stringify({
				         userName: userName.value,
				         phoneNumber: phoneNumber.value,
				         password: password.value
      				}));
      				
      				
      			mui.ajax('http://192.168.1.104:8080/DailyPhoto/rest/user/',{
      				data:JSON.stringify({
				         userName: userName.value,
				         phoneNumber: phoneNumber.value,
				         password: password.value
      				}),
      				dataType:'json',
      				contentType:'application/json',
      				type:'POST',
      				timeout:10000,
      				success:function(data){
      					if(data.success == true){
      						plus.ui.toast(data.message);
      						console.log(data);
      						mui.back();
      					}else{
      						plus.ui.toast(data.message);
      					}
      				},
      				error:function(){
      					
      				}
      			});
      			
      		});
      	});
    </script>
    <script src="http://192.168.1.104:8090/target/target-script-min.js#anonymous"></script>
    <style type="text/css">
    	.mui-btn{
    		width: 90%;
    	}
    </style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">注册</h1>
	</header>
	<div class="mui-content">
	    <form class="mui-input-group">
	        <div class="mui-input-row">
	            <label>用户名</label>
	            <input type="text" class="mui-input-clear" placeholder="用户名" id="userName">
	        </div>
	        <div class="mui-input-row">
	            <label>手机号</label>
	            <input type="text" class="mui-input-clear" placeholder="手机号" id="phoneNumber"	 >       
	        </div>
	        <div class="mui-input-row">
	            <label>密码</label>
	            <input type="password" class="mui-input-clear" placeholder="密码" id="password">
	        </div>
	      
	    </form>
	    <div class="mui-content-padded" align="center">
	        <button type="button" class="mui-btn mui-btn-blue" id="registerBtn">提交</button>
	    </div>
	</div>
</body>
</html>